package com.longsunhd.yum.buffalo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.longsunhd.yum.buffalo.R;
import com.longsunhd.yum.buffalo.bean.LoginBean;

import java.util.List;

/**
 * Created by 黄宣淇
 * on 2020/6/12 0012.
 */
public class ArrayAdapter extends BaseAdapter {
    private List<LoginBean> stringList;
    private Context mContext;
    public  static   interface DeleteI{
        void deleteClick(LoginBean userLoginBean);
    }
    public ArrayAdapter(Context context, List<LoginBean> lists){
        mContext =context;
        this. stringList =lists;

    }
    private   DeleteI deleteI;
    public void setDeleteI(DeleteI deleteI) {
        this.deleteI = deleteI;
    }
    @Override
    public int getCount() {
        return stringList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }


    @Override
    public long getItemId(int position) {
        return 0;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_list_simple,parent,false);
        TextView textView=  (TextView) view.findViewById(R.id.account_tv);
        ImageView imageView=  (ImageView) view.findViewById(R.id.account_delete);
        textView.setText(stringList.get(position).getData().getName());
        if(deleteI!=null){
            imageView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    deleteI.deleteClick(stringList.get(position));
                }
            });
        }
        return view;
    }
}
